import os
from pydantic import BaseSettings

class Settings(BaseSettings):
    # OpenAI API相关配置
    OPENAI_API_KEY: str = os.getenv("OPENAI_API_KEY", "your_openai_api_key")
    OPENAI_API_BASE: str = os.getenv("OPENAI_API_BASE", "https://api.openai.com/v1")
    
    # 云端大模型配置
    CLOUD_MODEL_PROVIDER: str = os.getenv("CLOUD_MODEL_PROVIDER", "openai")  # 目前支持openai和aliyun
    ALIYUN_API_KEY: str = os.getenv("ALIYUN_API_KEY", "your_aliyun_api_key")
    ALIYUN_API_BASE: str = os.getenv("ALIYUN_API_BASE", "https://dashscope.aliyuncs.com/api/v1/services/aigc/text-generation/generation")
    
    # Ollama兼容接口配置
    OLLAMA_HOST: str = os.getenv("OLLAMA_HOST", "0.0.0.0")
    OLLAMA_PORT: int = os.getenv("OLLAMA_PORT", 11434)
    
    # 模型映射配置
    MODEL_MAPPING: dict = {
        "llama2": "llama2-70b",
        "gpt-3.5-turbo": "gpt-35-turbo",
        "qwen": "qwen-max"
    }

    # 超时设置（秒）
    REQUEST_TIMEOUT: int = os.getenv("REQUEST_TIMEOUT", 60)

    # 日志配置
    LOG_LEVEL: str = os.getenv("LOG_LEVEL", "INFO")
    
    class Config:
        env_file = ".env"
        env_file_encoding = "utf-8"

settings = Settings()